package com.zx.mes.hyl.listener;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.apache.log4j.Logger;

/**
 * 重写ActivitiEventListener，对一些事件进行监听
 * @author hyl
 * @date 2018-1-24
 */
public class MyEventListener implements ActivitiEventListener {

    private Logger logger = Logger.getLogger(MyEventListener.class);

    @Override
    public void onEvent(ActivitiEvent event) {
        switch (event.getType()) {

            case JOB_EXECUTION_SUCCESS:
                logger.debug("一个job执行完毕!");
                break;

            case JOB_EXECUTION_FAILURE:
                logger.debug("一个job执行失败!");
                break;

            default:
                logger.debug("接收到事件:"+event.getType());
        }
    }

    @Override
    public boolean isFailOnException() {
        //此处不是很重要，如果业务很重要则返回true，异常会冒泡,当涉及多个数据库操作时，事务会回滚
        return false;
    }
}